package com.kfm.springboot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kfm.springboot.domain.Userinfo;
import com.kfm.springboot.mapper.UserinfoMapper;
import com.kfm.springboot.service.UserinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserinfoServiceImpl implements UserinfoService {

    @Autowired
    private UserinfoMapper mapper;

    @Override
    public Userinfo findById(String id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Userinfo> findAll(int pageNum, int pageSize, Userinfo userinfo) {
        PageHelper.startPage(pageNum, pageSize);
        return PageInfo.of(mapper.selectAll(userinfo));
    }

    @Override
    public int add(Userinfo userinfo) {
        return mapper.insertSelective(userinfo);
    }

    @Override
    public int modify(Userinfo userinfo) {
        return mapper.updateByPrimaryKeySelective(userinfo);
    }

    @Override
    public int remove(String id) {
        return mapper.deleteByPrimaryKey(id);
    }
}
